Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom suffix to identifiers in filestream input when needed #26669

Conversation

kvch
Copy link
Contributor

@kvch kvch commented Jul 1, 2021

What does this PR do?

This PR lets you inject suffixes to the state identifiers based on the configuration of the filestream input. For starters, it is needed by the container parser so tracking of different streams (stdout/stderr) can be done separately.

Why is it important?

Without this, the container input cannot be substituted with filestream input with a container parser.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
    - [ ] I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 1, 2021
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jul 1, 2021

💔 Build Failed

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2021-07-15T13:46:57.401+0000

  • Duration: 98 min 30 sec

  • Commit: d14cfb1

Test stats 🧪

Test Results
Failed 0
Passed 49282
Skipped 5396
Total 54678

Trends 🧪

Image of Build Times

Image of Tests

Steps errors 2

Expand to view the steps failures

x-pack/metricbeat-unitTest - mage build unitTest
  • Took 4 min 44 sec . View more details on here
  • Description: mage build unitTest
gsutil -m -q cp -a public-read ZmlsZWJlYXQtd2luZG93cy03LTMyLXdpbmRvd3MtNy0zMi1iaXRkMTRjZmIxODgxMzdhY
  • Took 0 min 2 sec . View more details on here
  • Description: gsutil -m -q cp -a public-read ZmlsZWJlYXQtd2luZG93cy03LTMyLXdpbmRvd3MtNy0zMi1iaXRkMTRjZmIxODgxMzdhYTc2NTUzZjY2ZmYzYTZkODA5MjcwZGI1YmQz gs://beats-ci-temp/ci/cache/

Log output

Expand to view the last 100 lines of log output

[2021-07-15T15:19:53.309Z] tests\system\test_lightmodules.py s                                      [ 10%]
[2021-07-15T15:20:50.830Z] + gsutil --version
[2021-07-15T15:20:52.245Z] Masking supported pattern matches of $FILE_CREDENTIAL
[2021-07-15T15:20:52.560Z] + gcloud auth activate-service-account --key-file ****
[2021-07-15T15:20:53.127Z] Activated service account credentials for: [beats-ci-gcs-plugin@elastic-ci-prod.iam.gserviceaccount.com]
[2021-07-15T15:20:53.440Z] + gsutil -m -q cp -a public-read cGFja2V0YmVhdC13aW5kb3dzLTEwLXdpbmRvd3MtMTBkMTRjZmIxODgxMzdhYTc2NTUzZjY2ZmYzYTZkODA5MjcwZGI1YmQz gs://beats-ci-temp/ci/cache/
[2021-07-15T15:21:05.753Z] tests\system\test_processors.py ........                                 [ 13%]
[2021-07-15T15:21:36.168Z] tests\system\test_reload.py ...                                          [ 14%]
[2021-07-15T15:21:36.168Z] tests\system\test_template.py s                                          [ 15%]
[2021-07-15T15:21:46.155Z] tests\system\test_timeseries.py .                                        [ 15%]
[2021-07-15T15:21:46.155Z] module\aerospike\test_aerospike.py s                                     [ 16%]
[2021-07-15T15:21:46.155Z] module\apache\test_apache.py ss                                          [ 17%]
[2021-07-15T15:21:46.155Z] module\ceph\test_ceph.py ssssssssssssssssssss                            [ 25%]
[2021-07-15T15:21:46.155Z] module\consul\test_consul.py ss                                          [ 25%]
[2021-07-15T15:21:46.155Z] module\couchbase\test_couchbase.py sss                                   [ 27%]
[2021-07-15T15:21:46.155Z] module\couchdb\test_couchdb.py s                                         [ 27%]
[2021-07-15T15:21:46.155Z] module\docker\test_docker.py sssssssss                                   [ 31%]
[2021-07-15T15:21:46.155Z] module\dropwizard\test_dropwizard.py sss                                 [ 32%]
[2021-07-15T15:21:46.155Z] module\elasticsearch\test_elasticsearch.py sssssssssss                   [ 36%]
[2021-07-15T15:21:46.155Z] module\envoyproxy\test_envoyproxy.py ss                                  [ 37%]
[2021-07-15T15:21:46.155Z] module\etcd\test_etcd.py ssssssss                                        [ 40%]
[2021-07-15T15:21:46.155Z] module\golang\test_golang.py s                                           [ 41%]
[2021-07-15T15:21:46.155Z] module\haproxy\test_haproxy.py sssssssssssssssssssssssss                 [ 51%]
[2021-07-15T15:21:54.278Z] module\http\test_http.py s.                                              [ 52%]
[2021-07-15T15:21:54.278Z] module\jolokia\test_jolokia.py ssss                                      [ 53%]
[2021-07-15T15:21:54.278Z] module\kafka\test_kafka.py ssssssssssssssssssss                          [ 61%]
[2021-07-15T15:21:54.278Z] module\kibana\test_kibana.py ss                                          [ 62%]
[2021-07-15T15:21:54.278Z] module\logstash\test_logstash.py sss                                     [ 63%]
[2021-07-15T15:21:54.278Z] module\memcached\test_memcached.py s                                     [ 64%]
[2021-07-15T15:21:54.278Z] module\mongodb\test_mongodb.py s                                         [ 64%]
[2021-07-15T15:21:54.278Z] module\munin\test_munin.py s                                             [ 65%]
[2021-07-15T15:21:54.278Z] module\mysql\test_mysql.py sssssss                                       [ 68%]
[2021-07-15T15:21:54.278Z] module\nats\test_nats.py ssssssssssssssssss                              [ 75%]
[2021-07-15T15:21:54.278Z] module\openmetrics\test_openmetrics.py s                                 [ 75%]
[2021-07-15T15:21:54.278Z] module\php_fpm\test_phpfpm.py s                                          [ 76%]
[2021-07-15T15:21:54.278Z] module\postgresql\test_postgresql.py ssssssssssssssssssss                [ 84%]
[2021-07-15T15:21:54.278Z] module\prometheus\test_prometheus.py sss                                 [ 85%]
[2021-07-15T15:21:54.278Z] module\redis\test_redis.py ssssssssssss                                  [ 90%]
[2021-07-15T15:23:49.728Z] module\system\test_system.py .....s..s...s.s.                            [ 96%]
[2021-07-15T15:23:49.728Z] module\traefik\test_traefik.py s                                         [ 97%]
[2021-07-15T15:23:49.728Z] module\uwsgi\test_uwsgi.py ss                                            [ 97%]
[2021-07-15T15:23:49.728Z] module\vsphere\test_vsphere.py sss                                       [ 99%]
[2021-07-15T15:23:49.728Z] module\zookeeper\test_zookeeper.py ss                                    [100%]
[2021-07-15T15:23:49.728Z] 
[2021-07-15T15:23:49.728Z] ============================== warnings summary ===============================
[2021-07-15T15:23:49.728Z] tests\system\test_lightmodules.py:57
[2021-07-15T15:23:49.728Z]   C:\Users\jenkins\workspace\PR-26669-10-1622a100-f060-466d-b6d6-cb658fe547e3\src\github.com\elastic\beats\metricbeat\tests\system\test_lightmodules.py:57: PytestCollectionWarning: cannot collect test class 'TestHTTPHandler' because it has a __init__ constructor (from: metricbeat/tests/system/test_lightmodules.py)
[2021-07-15T15:23:49.728Z]     class TestHTTPHandler(http.server.BaseHTTPRequestHandler):
[2021-07-15T15:23:49.728Z] 
[2021-07-15T15:23:49.728Z] -- Docs: https://docs.pytest.org/en/stable/warnings.html
[2021-07-15T15:23:49.728Z] - generated xml file: C:\Users\jenkins\workspace\PR-26669-10-1622a100-f060-466d-b6d6-cb658fe547e3\src\github.com\elastic\beats\metricbeat\build\TEST-python-unit.xml -
[2021-07-15T15:23:49.728Z] ============================ slowest 20 durations =============================
[2021-07-15T15:23:49.728Z] 16.94s call     metricbeat/tests/system/test_cmd.py::TestCommands::test_modules_list
[2021-07-15T15:23:49.728Z] 16.91s call     metricbeat/tests/system/test_cmd.py::TestCommands::test_modules_enable
[2021-07-15T15:23:49.728Z] 16.91s call     metricbeat/tests/system/test_cmd.py::TestCommands::test_modules_disable
[2021-07-15T15:23:49.728Z] 12.58s call     metricbeat/tests/system/test_reload.py::Test::test_start_stop
[2021-07-15T15:23:49.728Z] 11.78s call     metricbeat/tests/system/test_config.py::ConfigTest::test_service_name
[2021-07-15T15:23:49.728Z] 10.84s call     metricbeat/module/system/test_system.py::Test::test_process
[2021-07-15T15:23:49.728Z] 10.81s call     metricbeat/tests/system/test_cmd.py::TestCommands::test_modules_test_error
[2021-07-15T15:23:49.728Z] 10.68s call     metricbeat/tests/system/test_processors.py::Test::test_dropevent_with_condition
[2021-07-15T15:23:49.728Z] 9.58s call     metricbeat/tests/system/test_reload.py::Test::test_reload
[2021-07-15T15:23:49.728Z] 9.20s call     metricbeat/tests/system/test_processors.py::Test::test_dropfields_with_condition
[2021-07-15T15:23:49.728Z] 9.17s call     metricbeat/tests/system/test_processors.py::Test::test_dropevent_with_complex_condition
[2021-07-15T15:23:49.728Z] 9.09s call     metricbeat/tests/system/test_processors.py::Test::test_contradictory_multiple_actions
[2021-07-15T15:23:49.728Z] 9.07s call     metricbeat/tests/system/test_processors.py::Test::test_include_fields
[2021-07-15T15:23:49.728Z] 9.07s call     metricbeat/tests/system/test_processors.py::Test::test_multiple_actions
[2021-07-15T15:23:49.728Z] 8.95s call     metricbeat/tests/system/test_timeseries.py::TestTimeseries::test_enable_timeseries
[2021-07-15T15:23:49.728Z] 8.93s call     metricbeat/tests/system/test_base.py::Test::test_export_index_pattern_migration
[2021-07-15T15:23:49.728Z] 8.93s call     metricbeat/tests/system/test_base.py::Test::test_export_index_pattern
[2021-07-15T15:23:49.728Z] 8.90s call     metricbeat/tests/system/test_base.py::Test::test_export_config
[2021-07-15T15:23:49.728Z] 8.85s call     metricbeat/tests/system/test_base.py::Test::test_export_template
[2021-07-15T15:23:49.728Z] 8.79s call     metricbeat/module/system/test_system.py::Test::test_network
[2021-07-15T15:23:49.728Z] =========== 40 passed, 207 skipped, 1 warning in 400.64s (0:06:40) ============
[2021-07-15T15:23:49.988Z] >> python test: Unit Testing Complete
[2021-07-15T15:23:50.377Z] 
[2021-07-15T15:23:50.377Z] C:\Users\jenkins\workspace\PR-26669-10-1622a100-f060-466d-b6d6-cb658fe547e3\src\github.com\elastic\beats>FOR / %d IN ("ve") DO @IF EXIST "%d" rmdir /s /q "%d" 
[2021-07-15T15:23:52.592Z] 
[2021-07-15T15:23:52.592Z] C:\Users\jenkins\workspace\PR-26669-10-1622a100-f060-466d-b6d6-cb658fe547e3\src\github.com\elastic\beats>python .ci/scripts/pre_archive_test.py 
[2021-07-15T15:23:54.500Z] Copy .\metricbeat\build into build\metricbeat\build
[2021-07-15T15:23:54.500Z] Copy .\metricbeat\null\build into build\metricbeat\null\build
[2021-07-15T15:23:54.522Z] Running in C:\Users\jenkins\workspace\PR-26669-10-1622a100-f060-466d-b6d6-cb658fe547e3\src\github.com\elastic\beats\build
[2021-07-15T15:23:54.542Z] Recording test results
[2021-07-15T15:23:57.776Z] [Checks API] No suitable checks publisher found.
[2021-07-15T15:23:58.160Z] 
[2021-07-15T15:23:58.160Z] C:\Users\jenkins\workspace\PR-26669-10-1622a100-f060-466d-b6d6-cb658fe547e3\src\github.com\elastic\beats>go clean -modcache 
[2021-07-15T15:25:21.263Z] + gsutil --version
[2021-07-15T15:25:22.675Z] Masking supported pattern matches of $FILE_CREDENTIAL
[2021-07-15T15:25:22.993Z] + gcloud auth activate-service-account --key-file ****
[2021-07-15T15:25:23.598Z] Activated service account credentials for: [beats-ci-gcs-plugin@elastic-ci-prod.iam.gserviceaccount.com]
[2021-07-15T15:25:23.918Z] + gsutil -m -q cp -a public-read bWV0cmljYmVhdC13aW5kb3dzLTEwLXdpbmRvd3MtMTBkMTRjZmIxODgxMzdhYTc2NTUzZjY2ZmYzYTZkODA5MjcwZGI1YmQz gs://beats-ci-temp/ci/cache/
[2021-07-15T15:25:25.463Z] Stage "Packaging" skipped due to earlier failure(s)
[2021-07-15T15:25:25.515Z] Stage "Packaging-Pipeline" skipped due to earlier failure(s)
[2021-07-15T15:25:25.604Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-26669/src/github.com/elastic/beats
[2021-07-15T15:25:26.346Z] Running on Jenkins in /var/lib/jenkins/workspace/Beats_beats_PR-26669
[2021-07-15T15:25:26.414Z] [INFO] getVaultSecret: Getting secrets
[2021-07-15T15:25:26.478Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2021-07-15T15:25:27.215Z] + chmod 755 generate-build-data.sh
[2021-07-15T15:25:27.215Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-26669/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-26669/runs/10 FAILURE 5909548
[2021-07-15T15:25:27.215Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-26669/runs/10/steps/?limit=10000 -o steps-info.json
[2021-07-15T15:25:39.311Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-26669/runs/10/tests/?status=FAILED -o tests-errors.json

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 49282
Skipped 5396
Total 54678

@kvch kvch force-pushed the feature-filebeat-filestream-add-suffix-to-source-identifiers branch from 1b31602 to 43d1730 Compare July 1, 2021 15:10
@kvch kvch force-pushed the feature-filebeat-filestream-add-suffix-to-source-identifiers branch from 43d1730 to d4182cb Compare July 13, 2021 10:34
@kvch kvch changed the title Add custom suffix to identifiers in filestream input Add custom suffix to identifiers in filestream input when needed Jul 13, 2021
@kvch kvch marked this pull request as ready for review July 13, 2021 10:57
@kvch kvch added backport-v7.14.0 Automated backport with mergify backport-v7.15.0 Automated backport with mergify Team:Elastic-Agent Label for the Agent team labels Jul 13, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/agent (Team:Agent)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jul 13, 2021
@@ -49,6 +49,8 @@ type CommonConfig struct {
}

type Config struct {
Suffix string
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we want to name this field stream?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I named it Suffix because from outside it is the string that is supposed to be added to the end of the state IDs. It does not matter if it contains a stream name or emojis describing the weather. The only thing that is relevant that it is a suffix.

@@ -103,12 +106,16 @@ func NewConfig(pCfg CommonConfig, parsers []common.ConfigNamespace) (*Config, er
if err != nil {
return nil, fmt.Errorf("error while parsing container parser config: %+v", err)
}
if config.Stream != readjson.All {
suffix = config.Stream.String()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if suffix (the stream) is already set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one suffix is supported at the moment.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should error then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added an error.

@kvch kvch requested a review from urso July 13, 2021 13:31
@urso urso removed the backport-v7.14.0 Automated backport with mergify label Jul 13, 2021
@urso
Copy link

urso commented Jul 13, 2021

note: I removed backport to 7.14. We are past FF. I don't think this is a bug fix, right?

@urso
Copy link

urso commented Jul 15, 2021

Would be nice to have a test in parser_test checking that the stream is correctly extracted from the config. Otherwise LGTM

@kvch
Copy link
Contributor Author

kvch commented Jul 15, 2021

Added test

@kvch kvch merged commit 2876cfb into elastic:master Jul 15, 2021
mergify bot pushed a commit that referenced this pull request Jul 15, 2021
)

## What does this PR do?

This PR lets you inject suffixes to the state identifiers based on the configuration of the filestream input. For starters, it is needed by the container parser so tracking of different streams (stdout/stderr) can be done separately.

## Why is it important?

Without this, the container input cannot be substituted with filestream input with a container parser.

(cherry picked from commit 2876cfb)
kvch added a commit that referenced this pull request Jul 16, 2021
) (#26918)

## What does this PR do?

This PR lets you inject suffixes to the state identifiers based on the configuration of the filestream input. For starters, it is needed by the container parser so tracking of different streams (stdout/stderr) can be done separately.

## Why is it important?

Without this, the container input cannot be substituted with filestream input with a container parser.

(cherry picked from commit 2876cfb)

Co-authored-by: Noémi Ványi <kvch@users.noreply.github.com>
mdelapenya added a commit to mdelapenya/beats that referenced this pull request Jul 19, 2021
* master: (61 commits)
  Add disk queue unit tests based on the queuetest package
  [Heartbeat] redact authorization headers from logger (elastic#26892)
  Expose custom process metrics  (elastic#26912)
  [gcp/billing] always quote table name identifier (elastic#26870)
  Add Beats central management removal to BCs (elastic#26400)
  Add custom suffix to identifiers in filestream input when needed (elastic#26669)
  Update asa-ftd-pipeline.yml (elastic#26265)
  Use common host parser in vsphere module (elastic#26904)
  [automation] Update go release version 1.16.6 (elastic#26860)
  Skip flaky test: filestream and harvester group (elastic#26728)
  [Filebeat] Remove alias fields from Suricata and Traefik module mappings (elastic#26627)
  docs: apm-server.auth (elastic#26831)
  [Automation] Update elastic stack version to 8.0.0-2f008f4a for testing (elastic#26881)
  Clarify the scope of start/end multiline example (elastic#26786)
  [Heartbeat]: update Node.js version for synthetics (elastic#26867)
  [fix][httpjson] Fix incorrect key for template data (elastic#26848)
  [httpjson] Add value_type parameter to httpjson transforms (elastic#26847)
  [Heartbeat]: capture error from journey/end events (elastic#26781)
  [Winlogbeat] Fixes for wineventlog experimental api (elastic#26826)
  Set agent.id to Fleet Agent ID for each metric/log monitoring input (elastic#26776)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v7.15.0 Automated backport with mergify Team:Elastic-Agent Label for the Agent team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants